import { ShortCutsWindow } from "../../../component/window/ShortCutsWindow";
import { SkillInfo } from "../../model/SkillInfo";
import { NavSkillPanel } from "./NavSkillPanel";
import { GameConst } from "../../../component/gconst/GameConst";
import { CDItemData } from "../../cache/CDItem/CDItemData";
import { DataEvent } from "../../events/DataEvent";
import { ItemData } from "../../resource/info/ItemData";
import { ShortcutsItem } from "./ShortcutsItem";
import { ESkillUseType } from "../../../../Message/Public/ESkillUseType";
import { ObjCreate } from "../common/ObjCreate";
import { DragEvent } from "../../../../com/mui/events/DragEvent";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../mvc/ServerCommand";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { CDBackPackItem } from "../../cache/CDItem/CDBackPackItem";
import { Cache } from "../../cache/Cache";
import { SkillConst } from "../skill/SkillConst";
import { SkillRules } from "../../rules/SkillRules";
import { ESkillType } from "../../../../Message/Public/ESkillType";
import { LadderBattlefieldUtil } from "../ladderBattlefield/LadderBattlefieldUtil";
import { SkillsUtil } from "../../scene/skill/SkillsUtil";
import { BaseItem } from "../common/BaseItem";
import { MountItemRenderer } from "../mounts/cell/MountItemRenderer";
import { SPetInfo } from "../../../../Message/Game/SPetInfo";
import { ECategory } from "../../../../Message/Public/ECategory";
import { EProp } from "../../../../Message/Public/EProp";
import { SPetUpdate } from "../../../../Message/Game/SPetUpdate";
import { PetCoolDownInfo } from "../pet/PetCoolDownInfo";
import { MsgManager } from "../../manager/MsgManager";
import { Language } from "../../../../extend/language/Language";
import { SkillUseLaterUtil } from "../../scene/skill/useLater/SkillUseLaterUtil";
import { RolePlayer } from "../../scene/player/entity/RolePlayer";
import { ItemsUtil } from "./item/ItemsUtil";
import { PetUtil } from "../pet/info/PetUtil";
import { GButton } from "../../../../com/mui/controls/GButton";
import { ShortCutsCache } from "../../cache/ShortCutsCache";
type int = number;
//class Shortcuts
    
    export  class Shortcuts extends ShortCutsWindow
    {
        constructor()
        {
            super();
            this.itemsArray = [];
            this.init();
            return;
        }

        public updateNavSkill(arg1: SkillInfo): void
        {
            var loc1=null;
            if (this._navSkillPanel == null) 
            {
                this._navSkillPanel = new NavSkillPanel();
                this._navSkillPanel.x = 0;
                this._navSkillPanel.y = -39;
            }
            loc1 = this._navSkillPanel.addSkill(arg1);
            if (loc1) 
            {
                if (!(arg1.skillId == GameConst.CountryBuffSkillId) && !(arg1.skillId == GameConst.CountryCallTogetherKillId)) 
                {
                    this.itemsArray.push(loc1);
                }
                this.updateNavSkillPanelPos();
            }
            if (!this.contains(this._navSkillPanel)) 
            {
                this.addChild(this._navSkillPanel);
            }
            return;
        }

        public removeNavSkill(arg1: SkillInfo): void
        {
            var loc1=0;
            var loc2=null;
            if (this.itemsArray != null) 
            {
                loc1 = 0;
                while (loc1 < this.itemsArray.length) 
                {
                    loc2 = this.itemsArray[loc1];
                    if (!(loc2 == null) && !(loc2.dragSource == null) && loc2.dragSource is SkillInfo && !(arg1 == null) && !(arg1.tSkill == null) && (loc2.dragSource as SkillInfo).skillId == arg1.tSkill.skillId) 
                    {
                        this.itemsArray.splice(loc2);
                    }
                    ++loc1;
                }
            }
            if (this._navSkillPanel == null) 
            {
                return;
            }
            this._navSkillPanel.removeSkill(arg1);
            return;
        }

        public updateNavSkillCd(arg1: CDItemData, arg2: int): void
        {
            if (this._navSkillPanel != null) 
            {
                this._navSkillPanel.updateCD(arg1, arg2);
            }
            return;
        }

        /* internal  */updateNavSkillPanelPos(): void
        {
            if (this._navSkillPanel) 
            {
                if (this._isMuti) 
                {
                    if (this._isShow) 
                    {
                        this._navSkillPanel.x = 173;
                        this._navSkillPanel.y = -39;
                    }
                    else 
                    {
                        this._navSkillPanel.x = 173;
                        this._navSkillPanel.y = -117;
                    }
                }
                else if (this._isShow) 
                {
                    this._navSkillPanel.x = -11;
                    this._navSkillPanel.y = -39;
                }
                else 
                {
                    this._navSkillPanel.x = -11;
                    this._navSkillPanel.y = -78;
                }
            }
            return;
        }

        /* internal  */onSkillXPLearnedHandler(arg1: SkillInfo): void
        {
            var loc1=this.getXpScItem();
            if (loc1) 
            {
                loc1.dragSource = arg1;
            }
            return;
        }

        /* internal  */onBufferUpdate(arg1: Object): void
        {
            this.releshCanAttackMask();
            return;
        }

        /* internal  */canAttackMaskUpdateHandler(arg1: DataEvent): void
        {
            var loc5=null;
            var loc6=null;
            var loc1=int(arg1.data["category"]);
            var loc2=int(arg1.data["effect"]);
            var loc3=String(arg1.data["types"]);
            var loc4=Boolean(arg1.data["addCanNotAttackMask"]);
            if (loc1 == 0 && loc2 == 0 && (loc3 == null || loc3 == "")) 
            {
                return;
            }
            var loc7=0;
            var loc8=this.itemsArray;
            for(loc5 of loc8) 
            {
                if ((loc6 = loc5.dragSource as ItemData) == null) 
                {
                    continue;
                }
                if (!(loc1 == 0) && !(loc6.category == loc1)) 
                {
                    continue;
                }
                if (!(loc2 == 0) && !(loc6.effect == loc2)) 
                {
                    continue;
                }
                if (!(loc3 == null) && !(loc3 == "") && loc3.indexOf("#" + loc6.type.toString() + "#") < 0) 
                {
                    continue;
                }
                loc5.addCanNotAttackMaskValue = loc4;
            }
            return;
        }

        /* internal  */isLockItems(arg1: Boolean): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=this.itemsArray;
            for(loc1 of loc3) 
            {
                loc1.isDragAble = arg1;
                loc1.isThrowAble = arg1;
            }
            return;
        }

        /* internal  */releshCanAttackMask(): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=this.itemsArray;
            for(loc1 of loc3) 
            {
                loc1.updateIsCanNotAttackMask();
            }
            return;
        }

        /* internal  */getXpScItem(): ShortcutsItem
        {
            var loc1=null;
            var loc2=null;
            var loc3=1;
            while (loc3 <= 20) 
            {
                loc1 = this.itemsArray[loc3];
                if (loc1.dragSource) 
                {
                    loc2 = loc1.dragSource as SkillInfo;
                    if (loc2 && loc2.useType == ESkillUseType._ESkillUseTypeAuto) 
                    {
                        return loc1;
                    }
                }
                ++loc3;
            }
            return null;
        }

        public getScItemPos(arg1: int): Object /* flash.geom.Point */
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc6=0;
            var loc4=false;
            var loc5=1;
            while (loc5 <= 20) 
            {
                loc2 = this.itemsArray[loc5];
                if ((loc3 = loc2.dragSource as SkillInfo) && loc3.skillId == arg1) 
                {
                    loc1 = localToGlobal(new Object /* flash.geom.Point */(loc2.x, loc2.y));
                    loc4 = true;
                    break;
                }
                ++loc5;
            }
            if (loc4 == false) 
            {
                loc6 = 1;
                while (loc6 <= 20) 
                {
                    loc2 = this.itemsArray[loc6];
                    if (loc2.dragSource == null) 
                    {
                        loc1 = localToGlobal(new Object /* flash.geom.Point */(loc2.x, loc2.y));
                    }
                    ++loc6;
                }
            }
            return loc1;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=new Object /* flash.display.Sprite */();
            loc1.graphics.beginFill(0, 0.1);
            loc1.graphics.drawRect(0, 0, 37 * 10, 37);
            loc1.graphics.endFill();
            loc1.cacheAsBitmap = true;
            this.addChild(loc1);
            this._shrinkBtn = ObjCreate.createGButton("", 372, 2, 16, 35, this, "BarUpBtn");
            this._shrinkBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=1;
            while (loc4 <= 20) 
            {
                loc1 = new ShortcutsItem(loc4);
                loc1.x = (loc4 - 1) % 10 * 37;
                loc1.y = Math.floor((loc4 - 1) / 10) * -39;
                if (loc4 < 10) 
                {
                    loc1.setLabelTxt(loc4.toString());
                }
                else if (loc4 != 10) 
                {
                    if (loc4 > 10 && loc4 < 20) 
                    {
                        loc1.setLabelTxt("ctrl+" + loc4 % 10);
                    }
                    else if (loc4 == 20) 
                    {
                        loc1.setLabelTxt("ctrl+0");
                    }
                }
                else 
                {
                    loc1.setLabelTxt("0");
                }
                loc1.isDragAble = true;
                loc1.isDropAble = true;
                loc1.isThrowAble = true;
                this.addChild(loc1);
                this.itemsArray[loc4] = loc1;
                ++loc4;
            }
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onShortcutsClickHandler);
            this.addEventListener(DragEvent.Event_Move_In, this.moveInHandler);
            this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onSlortcutsDownHandler);
            this.addEventListener(DragEvent.Event_Throw_goods, this.throwHandler);
            this._isLock = false;
            NetDispatcher.addCmdListener(ServerCommand.SkillXPLearned, this.onSkillXPLearnedHandler);
            NetDispatcher.addCmdListener(ServerCommand.BufferUpdate, this.onBufferUpdate);
            Dispatcher.addEventListener(EventName.ShortcutUsableUpdate, this.canAttackMaskUpdateHandler);
            return;
        }

        public updateLabelByIndex(arg1: int, arg2: string): void
        {
            var loc1=this.itemsArray[arg1];
            if (loc1) 
            {
                loc1.setLabelTxt(arg2);
            }
            return;
        }

        public set isLock(arg1: Boolean)
        {
            var loc1=null;
            if (this._isLock != arg1) 
            {
                this._isLock = arg1;
                var loc2=0;
                var loc3=this.itemsArray;
                for(loc1 of loc3) 
                {
                    loc1.isDragAble = !this._isLock;
                    loc1.isThrowAble = !this._isLock;
                }
            }
            return;
        }

        public updateShortcutKey(arg1: Array<any>): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            while (loc4 < arg1.length) 
            {
                loc1 = arg1[loc4];
                if (typeof loc1.key === "int") 
                {
                    loc2 = this.itemsArray[loc1.key];
                    if (loc2) 
                    {
                        if (loc1.keyData) 
                        {
                            loc3 = loc1.keyData.shortcutsName;
                        }
                        else 
                        {
                            loc3 = "";
                        }
                        loc2.setLabelTxt(loc3);
                    }
                }
                ++loc4;
            }
            return;
        }

        public useItem(arg1: CDBackPackItem): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=this.itemsArray;
            for(loc2 of loc4) 
            {
                loc1 = loc2.dragSource as ItemData;
                if (!loc1) 
                {
                    continue;
                }
                if (!(loc2.amount > 0 && arg1.isCanCd(loc1))) 
                {
                    continue;
                }
                arg1.resetTotalTime();
                loc2.doCoolDown(arg1, true);
            }
            return;
        }

        public otherSkillCoolDown(arg1: int): void
        {
            var loc1=null;
            var loc2=null;
            var loc4=null;
            var loc3=-1;
            var loc5=1;
            while (loc5 < this.itemsArray.length) 
            {
                loc1 = this.itemsArray[loc5] as ShortcutsItem;
                loc2 = loc1.dragSource as SkillInfo;
                if (loc2 && !(loc2.skillId == arg1) && loc2.useTime == 0 && !(loc2.skillId == GameConst.CountryBuffSkillId) && !(loc2.skillId == GameConst.CountryCallTogetherKillId)) 
                {
                    loc4 = Cache.instance.timeCdCache.getSkillCd(loc2);
                    if (SkillConst.isNeedPublicCd(loc2)) 
                    {
                        if (loc4) 
                        {
                            if (loc4.isCoolDown == false) 
                            {
                                loc4.totalTime = 1000;
                                loc1.doPublicCd(loc4);
                            }
                        }
                        else if (loc4.isLessCd()) 
                        {
                            loc4.reset();
                            loc4.totalTime = 1000;
                            loc1.doPublicCd(loc4);
                        }
                    }
                }
                ++loc5;
            }
            return;
        }

        public useSkillItem(arg1: SkillInfo, arg2: Boolean=true, arg3: Boolean=true): void
        {
            var loc1=null;
            var loc2=null;
            var loc4=null;
            if (!arg1) 
            {
                return;
            }
            var loc3=-1;
            var loc5=1;
            while (loc5 < this.itemsArray.length) 
            {
                if (loc1 = (loc2 = this.itemsArray[loc5] as ShortcutsItem).dragSource as SkillInfo) 
                {
                    if (!SkillConst.isNoCoolDownBySKill(loc1.tSkill)) 
                    {
                        if (!(loc4 = Cache.instance.timeCdCache.getSkillCd(loc1))) 
                        {
                            loc4 = Cache.instance.timeCdCache.addSkillCd(loc1);
                        }
                        if (loc1.skillId != arg1.skillId) 
                        {
                            if (arg3) 
                            {
                                if (!SkillRules.isMarrySkill(loc1.tSkill)) 
                                {
                                    if (loc4) 
                                    {
                                        if (arg1.skillType == ESkillType._ESkillTypeSwitchBuff && loc1.skillType == ESkillType._ESkillTypeSwitchBuff && arg2) 
                                        {
                                            loc4.resetTotalTime();
                                            loc2.doCoolDown(loc4, true);
                                        }
                                        else if (SkillConst.isNeedPublicCd(loc1) && SkillConst.isNeedPublicCd(arg1)) 
                                        {
                                            if (loc4.isCoolDown != false) 
                                            {
                                                if (loc4.isLessCd()) 
                                                {
                                                    loc4.reset();
                                                    loc4.totalTime = 1000;
                                                    loc2.doPublicCd(loc4);
                                                }
                                            }
                                            else 
                                            {
                                                loc4.totalTime = 1000;
                                                loc2.doPublicCd(loc4);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else 
                        {
                            if (SkillRules.isMarrySkill(loc1.tSkill)) 
                            {
                                loc4.resetTotalTime();
                                loc2.doCoolDown(loc4, true);
                            }
                            else if (arg2) 
                            {
                                loc4.resetTotalTime();
                                loc2.doCoolDown(loc4, true);
                            }
                            else if (arg3) 
                            {
                                if (SkillConst.isNeedPublicCd(loc1)) 
                                {
                                    loc4.totalTime = 1000;
                                    loc2.doPublicCd(loc4);
                                }
                            }
                            loc3 = loc5;
                        }
                    }
                }
                ++loc5;
            }
            if (loc3 < 0) 
            {
                loc1 = Cache.instance.skill.getSkillInfoById(arg1.skillId);
                if (loc4 = Cache.instance.timeCdCache.getSkillCd(loc1)) 
                {
                    if (arg2) 
                    {
                        loc4.resetTotalTime();
                        loc4.startCoolDown();
                    }
                    else if (arg3) 
                    {
                        if (SkillConst.isNeedPublicCd(loc1)) 
                        {
                            loc4.totalTime = 1000;
                            loc4.startCoolDown();
                        }
                    }
                }
            }
            return;
        }

        public clearSkillCoolDown(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=1;
            while (loc4 < this.itemsArray.length) 
            {
                loc1 = this.itemsArray[loc4] as ShortcutsItem;
                loc2 = loc1.dragSource as SkillInfo;
                if (loc2) 
                {
                    if (!SkillConst.isNoCoolDownBySKill(loc2.tSkill)) 
                    {
                        loc3 = Cache.instance.timeCdCache.getSkillCd(loc2);
                        if (!loc3) 
                        {
                            loc3 = Cache.instance.timeCdCache.addSkillCd(loc2);
                        }
                        loc3.stopCoolDown();
                    }
                }
                ++loc4;
            }
            return;
        }

        public updateShortCuts(arg1, arg2: int=0): void
        {
            var loc2=0;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=null;
            var loc7=null;
            var loc8=null;
            var loc9=null;
            var loc10=0;
            this._cache = Cache.instance.shortCuts;
            var loc1=LadderBattlefieldUtil.isInLadderBattlefield ? Cache.instance.ladderBattlefield.ladderCareer : arg2;
            if (this._cache.jstr != null) 
            {
                Cache.instance.shortCuts.checkAndResaveForBaseCareer();
                loc10 = 1;
                while (loc10 < this._cache.ShortCutNum) 
                {
                    loc6 = this.itemsArray[loc10] as ShortcutsItem;
                    if ((loc3 = this._cache.getShortCutObj(loc10, loc1)) != null) 
                    {
                        loc4 = loc3.id;
                        loc5 = loc3.code;
                        loc7 = null;
                        if (typeof loc4 === "int") 
                        {
                            if (!(loc7 = Cache.instance.skill.getSkillInfoById(int(loc4)))) 
                            {
                                loc7 = Cache.instance.skill.getBaseSkillInfoById(int(loc4));
                            }
                            this._cache.addToShortCutsObj({"id": loc4, "code": loc5}, loc10, loc1);
                        }
                        if (loc7 && loc7.learned) 
                        {
                            loc6.dragSource = loc7;
                        }
                        else 
                        {
                            loc8 = Cache.instance.pack.mountsPackCache.getItemDataByUid(loc4 as string);
                            if (loc9 = Cache.instance.pet.getPetInfoByUid(loc4 as string)) 
                            {
                                loc6.dragSource = loc9;
                                this._cache.addToShortCutsObj({"id": loc4, "code": loc5}, loc10, loc1);
                            }
                            else if (loc8) 
                            {
                                loc6.dragSource = loc8;
                                this._cache.addToShortCutsObj({"id": loc4, "code": loc5}, loc10, loc1);
                            }
                            else 
                            {
                                if ((loc8 = Cache.instance.pack.backPackCache.getItemDataByUid(loc4 as string)) == null) 
                                {
                                    if (loc5 > 0) 
                                    {
                                        loc8 = new ItemData(loc5);
                                    }
                                }
                                if (loc8) 
                                {
                                    if (this.isPutItem(loc8)) 
                                    {
                                        loc6.dragSource = loc8;
                                        loc6.amount = Cache.instance.pack.backPackCache.getAllAoumtOfSameNameItem(loc8.itemInfo.item.name);
                                        this._cache.addToShortCutsObj({"id": loc4, "code": loc5}, loc10, loc1);
                                    }
                                }
                            }
                        }
                    }
                    else 
                    {
                        loc6.detory();
                    }
                    ++loc10;
                }
            }
            else 
            {
                loc2 = 1;
                while (loc2 < this._cache.ShortCutNum) 
                {
                    (this.itemsArray[loc2] as ShortcutsItem).detory();
                    ++loc2;
                }
            }
            if (this.isUseTopSC()) 
            {
                this._isShow = true;
            }
            else 
            {
                this._isShow = false;
            }
            this.onBtnClickHandler(null);
            if (this._isLaterRemoveMarrySkill) 
            {
                this.removeMarrySkill();
            }
            return;
        }

        /* internal  */getShortCutKey(arg1: int, arg2: int=-1): int
        {
            if (arg2 == -1) 
            {
                arg2 = Cache.instance.role.careerEnabled;
            }
            return arg1 + 10000 * arg2;
        }

        public onSkillListRes(arg1: Array<any>): void
        {
            var loc1=null;
            var loc2=null;
            this.clearSkillCareerItem();
            var loc3=0;
            var loc4=arg1;
            for(loc1 of loc4) 
            {
                if (!loc1.learned) 
                {
                    continue;
                }
                if (SkillsUtil.instance.isAutoAddToShortCart2(loc1.tSkill)) 
                {
                    this.updateNavSkill(loc1);
                    continue;
                }
                loc2 = this.hasShortItemById(loc1.skillId);
                if (!loc2) 
                {
                    continue;
                }
                loc2.dragSource = loc1;
            }
            return;
        }

        /* internal  */clearSkillCareerItem(): void
        {
            var loc1=null;
            if (this._navSkillPanel) 
            {
                this._navSkillPanel.clearSkillList();
            }
            var loc2=0;
            var loc3=this.itemsArray;
            for(loc1 of loc3) 
            {
                if (!(loc1 && loc1.dragSource && loc1.dragSource is SkillInfo && (loc1.dragSource as SkillInfo).isCareerSkill)) 
                {
                    continue;
                }
                loc1.detory();
            }
            return;
        }

        /* internal  */hasShortItemById(arg1: int): ShortcutsItem
        {
            var loc2=null;
            var loc1=Cache.instance.shortCuts;
            var loc3=0;
            var loc4=loc1;
            for (loc2 in loc4) 
            {
                if (loc1[loc2].id != arg1) 
                {
                    continue;
                }
                this.itemsArray[loc2];
            }
            return null;
        }

        /* internal  */moveInHandler(arg1: DragEvent): void
        {
            var loc1=undefined;
            var loc6=null;
            var loc7=0;
            var loc8=0;
            var loc9=null;
            var loc10=null;
            var loc11=0;
            var loc12=null;
            var loc13=null;
            var loc14=null;
            var loc15=null;
            if (typeof arg1.dragItem === "baseitem") 
            {
                loc1 = arg1.dragItem as BaseItem;
            }
            else if (typeof arg1.dragItem === "mountitemrenderer") 
            {
                loc1 = arg1.dragItem as MountItemRenderer;
            }
            var loc2=arg1.dropItem as ShortcutsItem;
            var loc3;
            if ((loc3 = arg1.dragSouce as ItemData) && SkillsUtil.isUsableSkill(loc3)) 
            {
                return;
            }
            var loc4=new Object();
            var loc5=false;
            if (loc1 && loc2) 
            {
                if (loc1 is ShortcutsItem && !(null == loc1.dragSource) && loc2 is ShortcutsItem) 
                {
                    loc6 = loc1 as ShortcutsItem;
                    if (loc2.dragSource) 
                    {
                        loc7 = loc6.pos;
                        loc8 = loc2.pos;
                        if (loc7 == loc8) 
                        {
                            return;
                        }
                        loc9 = this._cache.getShortCutObj(loc7);
                        loc10 = this._cache.getShortCutObj(loc8);
                        loc4 = loc2.dragSource;
                        loc11 = loc2.amount;
                        loc2.dragSource = loc6.dragSource;
                        loc2.amount = loc6.amount;
                        loc6.dragSource = loc4;
                        loc6.amount = loc11;
                        this._cache.addToShortCutsObj(loc10, loc7);
                        this._cache.addToShortCutsObj(loc9, loc8);
                        loc5 = true;
                    }
                    else 
                    {
                        loc2.dragSource = loc6.dragSource;
                        loc2.amount = loc6.amount;
                        loc6.dragSource = null;
                        loc9 = this._cache.getShortCutObj(loc6.pos);
                        this._cache.addToShortCutsObj(loc9, (loc2 as ShortcutsItem).pos);
                        this._cache.addToShortCutsObj(null, (loc1 as ShortcutsItem).pos);
                        loc5 = true;
                    }
                }
                else if (typeof arg1.dragSouce === "skillinfo") 
                {
                    loc13 = arg1.dragSouce as SkillInfo;
                    this._cache.addToShortCutsObj({"id": loc13.skillId, "code": loc13.skillId}, loc2.pos);
                    loc12 = Cache.instance.timeCdCache.getSkillCd(loc13);
                    loc2.doCoolDown(loc12);
                    loc2.dragSource = loc13;
                    loc5 = true;
                }
                else if (typeof arg1.dragSouce === "itemdata") 
                {
                    loc14 = arg1.dragSouce as ItemData;
                    if (this.isPutItem(loc14)) 
                    {
                        this._cache.addToShortCutsObj({"id": loc14.uid, "code": loc14.itemCode}, loc2.pos);
                        loc12 = Cache.instance.timeCdCache.getCdTime(loc14);
                        loc2.doCoolDown(loc12);
                        loc2.dragSource = loc14;
                        loc2.amount = Cache.instance.pack.backPackCache.getAllAoumtOfSameNameItem(loc14.itemInfo.item.name);
                        loc5 = true;
                    }
                }
                else if (typeof arg1.dragSouce === "spetinfo") 
                {
                    loc15 = arg1.dragSouce as SPetInfo;
                    this._cache.addToShortCutsObj({"id": loc15.uid, "code": loc15.code}, loc2.pos);
                    loc2.dragSource = loc15;
                    loc5 = true;
                }
            }
            if (loc5) 
            {
                this._cache.saveShortCutData();
            }
            return;
        }

        /* internal  */isPutItem(arg1: ItemData): Boolean
        {
            return arg1.category == ECategory._ECategoryDrug || arg1.category == ECategory._ECategoryProp && arg1.type == EProp._EPropPassToCity;
        }

        /* internal  */isPutSkill(arg1: SkillInfo): Boolean
        {
            return arg1.useType == ESkillUseType._ESkillUseTypeInitiative;
        }

        /* internal  */throwHandler(arg1: DragEvent): void
        {
            var loc1=arg1.dragItem as ShortcutsItem;
            var loc2=arg1.dropItem as BaseItem;
            loc1.dragSource = null;
            this._cache.addToShortCutsObj(null, loc1.pos);
            this._cache.saveShortCutData();
            return;
        }

        /* internal  */onSlortcutsDownHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.isDraging = false;
            this.addEventListener(flash.events.MouseEvent.MOUSE_MOVE, this.onShortcutMoveHandler);
            return;
        }

        /* internal  */onShortcutMoveHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.isDraging = true;
            return;
        }

        public onShortcutsClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target as ShortcutsItem;
            if (!this.isDraging) 
            {
                this.useShortCutItem(loc1);
            }
            return;
        }

        public updateSkill(arg1: SkillInfo): void
        {
            var loc1=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc2=1;
            while (loc2 < this.itemsArray.length) 
            {
                if (loc4 = (loc3 = this.itemsArray[loc2] as ShortcutsItem).dragSource as SkillInfo) 
                {
                    if (loc4.skillName == arg1.skillName) 
                    {
                        if (loc1 == null) 
                        {
                            loc1 = Cache.instance.timeCdCache.updateSkillCd(arg1);
                        }
                        loc3.dragSource = arg1;
                        loc3.doCoolDown(loc1);
                        this._cache.addToShortCutsObj({"id": arg1.skillId, "code": arg1.skillId}, loc2);
                    }
                }
                ++loc2;
            }
            if (loc1 == null) 
            {
                Cache.instance.timeCdCache.updateSkillCd(arg1);
                loc5 = {"id": arg1.skillId, "code": arg1.skillId};
                this._cache.addToShortCutsObj(loc5, loc2);
            }
            this._cache.saveShortCutData();
            return;
        }

        public removeMarrySkill(): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=this.itemsArray;
            for(loc1 of loc3) 
            {
                if (!(loc1 && loc1.dragSource && loc1.dragSource is SkillInfo && (loc1.dragSource as SkillInfo).isMarrySkill)) 
                {
                    continue;
                }
                loc1.detory();
                this._cache.addToShortCutsObj(null, loc1.pos);
            }
            if (!this._cache) 
            {
                this._isLaterRemoveMarrySkill = true;
                return;
            }
            this._cache.saveShortCutData();
            return;
        }

        /* internal  */updateItemData(arg1: DataEvent): void
        {
            var loc1=arg1.data["oldItemData"] as ItemData;
            var loc2=arg1.data["newItemData"] as ItemData;
            this.findItemAndUpdate(loc1, loc2);
            return;
        }

        public updatePetInfo(arg1: SPetUpdate): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=false;
            var loc4=1;
            while (loc4 < this.itemsArray.length) 
            {
                loc2 = this.itemsArray[loc4] as ShortcutsItem;
                loc1 = loc2.dragSource as SPetInfo;
                if (loc1) 
                {
                    if (arg1.petInfo.uid != loc1.uid) 
                    {
                        this.setAllPetCD(arg1);
                    }
                    else if (arg1.updateType != 2) 
                    {
                        if (arg1.petInfo.status != 2) 
                        {
                            loc2.dragSource = arg1.petInfo;
                        }
                        else 
                        {
                            this.setAllPetCD(arg1);
                            loc2.dragSource = arg1.petInfo;
                            break;
                        }
                        break;
                    }
                    else 
                    {
                        loc2.detory();
                        break;
                    }
                }
                ++loc4;
            }
            return;
        }

        /* internal  */setAllPetCD(arg1: SPetUpdate): void
        {
            var loc1=null;
            var loc3=null;
            var loc2=new PetCoolDownInfo(arg1.petInfo.uid, arg1.petInfo.status);
            loc1 = Cache.instance.timeCdCache.addPetCd(loc2);
            var loc4=0;
            while (loc4 < this.itemsArray.length) 
            {
                if ((loc3 = this.itemsArray[loc4] as ShortcutsItem) && loc3.dragSource is SPetInfo) 
                {
                    loc3.setCdTime(loc1);
                }
                ++loc4;
            }
            return;
        }

        public findItemAndUpdate(arg1: ItemData, arg2: ItemData=null): void
        {
            var loc2=null;
            var loc3=null;
            if (arg2 == null) 
            {
                arg2 = arg1;
            }
            var loc1=false;
            var loc4=1;
            while (loc4 < this.itemsArray.length) 
            {
                if (loc2 = (loc3 = this.itemsArray[loc4] as ShortcutsItem).dragSource as ItemData) 
                {
                    if (loc2.itemInfo.item.category == ECategory._ECategoryDrug && loc2.itemInfo.item.name == arg1.itemInfo.item.name) 
                    {
                        this._cache.addToShortCutsObj({"id": arg2.uid, "code": arg2.itemCode}, loc4);
                        loc1 = true;
                    }
                }
                ++loc4;
            }
            if (loc1) 
            {
                this._cache.saveShortCutData();
            }
            return;
        }

        public updataShortcutsSameItem(arg1: ItemData): void
        {
            this.findItemAndUpdate(arg1);
            return;
        }

        public getItemByIndex(arg1: int): ShortcutsItem
        {
            return this.itemsArray[arg1];
        }

        /* internal  */useShortCutItem(arg1: ShortcutsItem): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            if (arg1 == null) 
            {
                return;
            }
            if (arg1.playingEffect) 
            {
                if (typeof arg1.dragSource === "itemdata") 
                {
                    MsgManager.showRollTipsMsg(Language.getString(51077));
                }
                else if (typeof arg1.dragSource === "skillinfo") 
                {
                    SkillUseLaterUtil.addSkillUseLater(arg1.dragSource as SkillInfo);
                    MsgManager.showRollTipsMsg(Language.getString(51078));
                }
                return;
            }
            if (arg1.dragSource) 
            {
                if (typeof arg1.dragSource === "skillinfo") 
                {
                    loc1 = arg1.dragSource as SkillInfo;
                    if (loc1.skillId != SkillConst.Rest) 
                    {
                        if (loc1.skillId != SkillConst.Mount) 
                        {
                            if (loc1.skillId != SkillConst.Fish) 
                            {
                                Dispatcher.dispatchEvent(new DataEvent(EventName.SkillUseSkill, loc1));
                            }
                            else 
                            {
                                Dispatcher.dispatchEvent(new DataEvent(EventName.FishGotoFish));
                            }
                        }
                        else 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.KeyControllMounts));
                        }
                    }
                    else 
                    {
                        RolePlayer.instance.readyRest();
                    }
                }
                else if (typeof arg1.dragSource === "itemdata") 
                {
                    loc2 = arg1.dragSource as ItemData;
                    if (arg1.amount <= 0) 
                    {
                        return;
                    }
                    if (ItemsUtil.isPetEnerg(loc2)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PetFeedInPack, loc2));
                    }
                    else if (loc3 = Cache.instance.pack.backPackCache.getSameItemByItemData(loc2)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Use, loc3));
                    }
                }
                else if (typeof arg1.dragSource === "spetinfo") 
                {
                    loc4 = arg1.dragSource as SPetInfo;
                    if (PetUtil.isBattled(loc4)) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PetRest));
                    }
                    else 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PetBattle, loc4));
                    }
                }
            }
            return;
        }

        public updateShortcuts(arg1: Map<any, any> /* flash.utils.Dictionary */): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for (loc1 in loc4) 
            {
                loc2 = this.itemsArray[loc1];
                loc2.dragSource = arg1[loc1];
            }
            return;
        }

        public useShortCut(arg1: int): void
        {
            this.useShortCutItem(this.itemsArray[arg1] as ShortcutsItem);
            return;
        }

        public getSkillByKey(arg1: int): SkillInfo
        {
            var loc1=this.itemsArray[arg1] as ShortcutsItem;
            if (loc1) 
            {
                return loc1.dragSource as SkillInfo;
            }
            return null;
        }

        public updateItemNumber(): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=null;
            var loc5=0;
            var loc6=this.itemsArray;
            for(loc4 of loc6) 
            {
                loc2 = loc4.dragSource as ItemData;
                if (!loc2) 
                {
                    continue;
                }
                loc4.amount = Cache.instance.pack.backPackCache.getAllAoumtOfSameNameItem(loc2.itemInfo.item.name);
            }
            return;
        }

        public addItemToShortcuts(arg1: Object, arg2: Boolean=false): void
        {
            var loc1=null;
            var loc3=0;
            var loc4=null;
            var loc7=null;
            var loc8=null;
            var loc2=-1;
            var loc5=false;
            var loc6=this.itemsArray.length;
            if (arg2 == false) 
            {
                loc6 = 11;
            }
            if (typeof arg1 === "skillinfo") 
            {
                loc7 = arg1 as SkillInfo;
                if (!this.isPutSkill(loc7)) 
                {
                    return;
                }
                if (loc7.skillId != SkillConst.Fish) 
                {
                    loc4 = Cache.instance.timeCdCache.getSkillCd(loc7);
                    loc3 = 1;
                    while (loc3 < loc6) 
                    {
                        loc1 = this.itemsArray[loc3] as ShortcutsItem;
                        if (loc1.dragSource != null) 
                        {
                            if (loc1.itemName == loc7.skillName) 
                            {
                                loc1.dragSource = loc7;
                                if (loc4) 
                                {
                                    loc1.doCoolDown(loc4);
                                }
                                this._cache.addToShortCutsObj({"id": loc7.skillId, "code": loc7.skillId}, loc3);
                                loc2 = 0;
                                loc5 = true;
                            }
                        }
                        else if (loc2 == -1) 
                        {
                            loc2 = loc3;
                        }
                        ++loc3;
                    }
                }
                else if ((loc2 = this.addSkillToBack(loc7)) == 0) 
                {
                    loc5 = true;
                }
                if (loc2 > 0) 
                {
                    this._cache.addToShortCutsObj({"id": loc7.skillId, "code": loc7.skillId}, loc2);
                    loc1 = this.itemsArray[loc2] as ShortcutsItem;
                    loc1.dragSource = arg1;
                    if (loc4) 
                    {
                        loc1.doCoolDown(loc4);
                    }
                    loc5 = true;
                }
            }
            else if (typeof arg1 === "itemdata") 
            {
                loc8 = arg1 as ItemData;
                if (this.isPutItem(loc8)) 
                {
                    loc4 = Cache.instance.timeCdCache.getCdTime(loc8);
                    loc3 = 1;
                    while (loc3 < loc6) 
                    {
                        loc1 = this.itemsArray[loc3] as ShortcutsItem;
                        if (loc1.dragSource != null) 
                        {
                            if (loc1.itemName == loc8.itemInfo.item.name) 
                            {
                                loc1.doCoolDown(loc4);
                                this._cache.addToShortCutsObj({"id": loc8.uid, "code": loc8.itemCode}, loc3);
                                loc2 = 0;
                                loc5 = true;
                            }
                        }
                        else if (loc2 != 0) 
                        {
                            loc2 = loc3;
                        }
                        ++loc3;
                    }
                    if (loc2 > 0) 
                    {
                        this._cache.addToShortCutsObj({"id": loc8.uid, "code": loc8.itemCode}, loc2);
                        loc1 = this.itemsArray[loc2] as ShortcutsItem;
                        loc1.doCoolDown(loc4);
                        loc1.dragSource = arg1;
                        loc1.amount = Cache.instance.pack.backPackCache.getAllAoumtOfSameNameItem(loc8.itemInfo.item.name);
                        loc5 = true;
                    }
                }
            }
            if (loc5) 
            {
                this._cache.saveShortCutData();
            }
            return;
        }

        /* internal  */addSkillToBack(arg1: SkillInfo): int
        {
            var loc1=null;
            var loc2=-1;
            var loc3=1;
            while (loc3 < this.itemsArray.length) 
            {
                loc1 = this.itemsArray[loc3] as ShortcutsItem;
                if (loc1.dragSource != null) 
                {
                    if (loc1.itemName == arg1.skillName) 
                    {
                        loc1.dragSource = arg1;
                        this._cache.addToShortCutsObj({"id": arg1.skillId, "code": arg1.skillId}, loc3);
                        loc2 = 0;
                    }
                }
                else if (loc2 != 0) 
                {
                    loc2 = loc3;
                }
                ++loc3;
            }
            return loc2;
        }

        public resetPos(arg1: Boolean): void
        {
            var loc1=null;
            this._isMuti = arg1;
            var loc2=11;
            while (loc2 <= 15) 
            {
                loc1 = this.itemsArray[loc2];
                if (arg1) 
                {
                    loc1.x = 185 + (loc2 - 1) % 10 * 37;
                    loc1.y = -78;
                }
                else 
                {
                    loc1.x = (loc2 - 1) % 10 * 37;
                    loc1.y = -39;
                }
                ++loc2;
            }
            this.updateNavSkillPanelPos();
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._isShow) 
            {
                this.showSc(11, 20, true);
                this._shrinkBtn.styleName = "BarDownBtn";
                this._isShow = false;
            }
            else 
            {
                this.showSc(11, 20, false);
                this._shrinkBtn.styleName = "BarUpBtn";
                this._isShow = true;
            }
            this.updateNavSkillPanelPos();
            return;
        }

        /* internal  */showByStatus(arg1: int): void
        {
            if (this._isMuti) 
            {
                if (arg1 != 0) 
                {
                    if (arg1 != 1) 
                    {
                        if (arg1 == 2) 
                        {
                            this.showSc(11, 20, true);
                            this._shrinkBtn.styleName = "BarDownBtn";
                        }
                    }
                    else 
                    {
                        this.showSc(11, 15, false);
                        this._shrinkBtn.styleName = "BarUpBtn";
                    }
                }
                else 
                {
                    this.showSc(11, 20, false);
                    this._shrinkBtn.styleName = "BarUpBtn";
                }
            }
            else if (arg1 != 0) 
            {
                if (arg1 == 1) 
                {
                    this.showSc(11, 20, true);
                    this._shrinkBtn.styleName = "BarDownBtn";
                }
            }
            else 
            {
                this.showSc(11, 20, false);
                this._shrinkBtn.styleName = "BarUpBtn";
            }
            return;
        }

        /* internal  */showSc(arg1: int, arg2: int, arg3: Boolean): void
        {
            var loc1=null;
            var loc2=arg1;
            while (loc2 <= arg2) 
            {
                (loc1 = this.itemsArray[loc2]).visible = arg3;
                ++loc2;
            }
            return;
        }

        /* internal  */isUseTopSC(): Boolean
        {
            var loc1=false;
            var loc2=null;
            var loc3=11;
            while (loc3 <= 20) 
            {
                loc2 = this.itemsArray[loc3];
                if (loc2.dragSource) 
                {
                    loc1 = true;
                    break;
                }
                ++loc3;
            }
            return loc1;
        }

        public /* var */itemsArray: Array<any>;

        /* internal */ /* var */_topShortcuts: Object /* flash.display.Sprite */;

        /* internal */ /* var */_currentScItem: ShortcutsItem;

        /* internal */ /* var */currentItemData: ItemData;

        /* internal */ /* var */_shrinkBtn: GButton;

        /* internal */ /* var */_navSkillPanel: NavSkillPanel;

        /* internal */ /* var */isDraging: Boolean=false;

        /* internal */ /* var */_isMuti: Boolean;

        /* internal */ /* var */_cache: ShortCutsCache;

        /* internal */ /* var */_isLaterRemoveMarrySkill: Boolean=false;

        /* internal */ /* var */_isLock: Boolean=false;

        /* internal */ /* var */_isShow: Boolean;
    }
